package com.zlx.sharelive.fragment;

import android.app.Dialog;
import android.content.Intent;
import android.media.MediaMetadataRetriever;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.util.Patterns;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.webkit.URLUtil;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lzj.pass.dialog.PayPassDialog;
import com.lzj.pass.dialog.PayPassView;
import com.zlx.module_base.base_api.res_data.BaseBean;
import com.zlx.module_base.base_api.res_data.DeleteFocusedBean;
import com.zlx.module_base.base_api.res_data.GuessLikeVideoBody;
import com.zlx.module_base.base_api.res_data.HomeBannerBean;
import com.zlx.module_base.base_api.res_data.HomeVideoBean;
import com.zlx.module_base.base_api.res_data.PurchaseVideoBean;
import com.zlx.module_base.base_api.res_data.QueryByBean;
import com.zlx.module_base.base_api.res_data.UpdateUserBean;
import com.zlx.module_base.base_api.res_data.VideoBean;
import com.zlx.module_base.base_api.util.ApiUtil;
import com.zlx.module_base.base_fg.BaseFg;
import com.zlx.module_base.base_util.SPUtil;
import com.zlx.module_network.api1.livedata.BaseObserver;
import com.zlx.module_network.api1.livedata.BaseObserverCallBack;
import com.zlx.module_network.bean.ApiResponse;
import com.zlx.sharelive.Constants;
import com.zlx.sharelive.R;
import com.zlx.sharelive.activity.HomeLinkAc;
import com.zlx.sharelive.activity.HomepageAc;
import com.zlx.sharelive.activity.LoginAc;
import com.zlx.sharelive.activity.MemberAc;
import com.zlx.sharelive.activity.OthersHomepageAc;
import com.zlx.sharelive.activity.VideoDetailsAc;
import com.zlx.sharelive.adapter.CommonRecyclerViewAdapter;
import com.zlx.sharelive.adapter.CommonRecyclerViewHolder;
import com.zlx.sharelive.utils.GlideImgManager;
import com.zlx.sharelive.utils.StringUt;

import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 简介
 */
public class SummaryFg extends BaseFg {

    @BindView(R.id.tv_summary)
    TextView tv_summary;
    @BindView(R.id.iv_summary_head)
    ImageView iv_summary_head;
    @BindView(R.id.tv_summary_nickname)
    TextView tv_summary_nickname;
    @BindView(R.id.rv_summary_data)
    RecyclerView rv_summary_data;
    @BindView(R.id.iv_summary_vip)
    ImageView iv_summary_vip;
    @BindView(R.id.iv_summary_goddess)
    ImageView iv_summary_goddess;
    @BindView(R.id.tv_summary_time)
    TextView tv_summary_time;
    @BindView(R.id.tv_summary_number)
    TextView tv_summary_number;
    @BindView(R.id.tv_attention)
    TextView tv_attention;
    @BindView(R.id.tv_like_count)
    TextView tv_like_count;
    @BindView(R.id.iv_praise)
    ImageView iv_praise;
    @BindView(R.id.iv_advertisement)
    ImageView iv_advertisement;

    private String over;
    private int videoCount;
    private String uid;
    private String id;
    private String url;
    private String title;
    private List<VideoBean.InfoDTO.RecordsDTO> mList = new ArrayList<>();
    private CommonRecyclerViewAdapter<VideoBean.InfoDTO.RecordsDTO> mAdapter;


    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case 1:
                    mAdapter.notifyItemChanged(msg.arg1);
                    break;
            }
        }
    };

    public static SummaryFg getInstance(String title, String id) {
        SummaryFg summaryFg = new SummaryFg();
        Bundle bundle = new Bundle();
        bundle.putSerializable("title", title);
        bundle.putSerializable("id", id);
        summaryFg.setArguments(bundle);
        return summaryFg;
    }


    @Override
    protected int getLayoutId() {
        return R.layout.fg_summary;
    }


    @Override
    protected void initViews() {
        super.initViews();

        title = getArguments().getString("title");
        id = getArguments().getString("id");
        tv_summary.setText(title);
        getHomeVideo();
        getGuessLikeVideo();
        initRecyclerView();
        getHomeRollAnnouncement();
    }

    private void getHomeRollAnnouncement() {
        ApiUtil.getHomeApi().getHomeBannerList("2").observe(this, new BaseObserver<>(new BaseObserverCallBack<ApiResponse<HomeBannerBean>>() {
            @Override
            public void onSuccess(ApiResponse<HomeBannerBean> data) {
                if (null != data) {
                    if (null != data.getData()) {
                        if (null != data.getData().getInfo()) {
                            if (data.getData().getInfo().size() > 0) {
                                url = data.getData().getInfo().get(0).getLink();
                                GlideImgManager.loadImage(getContext(), data.getData().getInfo().get(0).getImg(), iv_advertisement);
                            }
                        }
                    }
                }
            }
        }));
    }

    /**
     * 根据用户id查询个人信息
     */
    private void queryById() {
        ApiUtil.getLoginApi().queryById(SPUtil.getToken(getContext()),(String) SPUtil.get(getContext(), Constants.SP_ID, ""))
                .observe(getViewLifecycleOwner(), new BaseObserver<>(new BaseObserverCallBack<ApiResponse<QueryByBean>>() {
                    @Override
                    public void onSuccess(ApiResponse<QueryByBean> data) {
                        if (null != data) {
                            if (null != data.getData()) {
                                if (null != data.getData().getInfo()) {
                                    if (data.getData().getInfo().size() > 0) {
                                        if (null != data.getData().getInfo().get(0).getResult()) {
                                            if (!StringUt.isEmpty(data.getData().getInfo().get(0).getResult().getVideoCount())) {
                                                videoCount = Integer.valueOf(data.getData().getInfo().get(0).getResult().getVideoCount());
                                                if (!StringUt.isEmpty(data.getData().getInfo().get(0).getResult().getMoney())) {
                                                    over = data.getData().getInfo().get(0).getResult().getMoney();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();

                    }
                }));
    }

    /**
     * 猜你喜欢
     */
    private void getGuessLikeVideo() {
        GuessLikeVideoBody guessLikeVideoBody = new GuessLikeVideoBody();
        guessLikeVideoBody.setP("1");
        guessLikeVideoBody.setType1("2");
        ApiUtil.getVideoApi().getGuessLikeVideo(SPUtil.getToken(getContext()),
                guessLikeVideoBody).observe(getViewLifecycleOwner(), new BaseObserver<>(new BaseObserverCallBack<ApiResponse<VideoBean>>() {
            @Override
            public void onSuccess(ApiResponse<VideoBean> data) {
                mList.clear();
                if (null != data) {
                    if (null != data.getData()) {
                        if (null != data.getData().getInfo()) {
                            if (data.getData().getInfo().size() > 0) {
                                if (null != data.getData().getInfo().get(0).getRecords()) {
                                    mList.addAll(data.getData().getInfo().get(0).getRecords());
                                }
                            }
                        }
                    }
                }
                mAdapter.notifyDataSetChanged();

                for (int i = 0; i < mList.size(); i++) {
                    int finalI = i;
                    new Thread() {
                        @Override
                        public void run() {
                            super.run();
                            if (isValid(mList.get(finalI).getVideo()) == true) {
                                if (!StringUt.isEmpty(getPlayTime(mList.get(finalI).getVideo()))) {
                                    String time = getFormatedDateTime("mm:ss", Long.valueOf(getPlayTime(mList.get(finalI).getVideo())));
                                    mList.get(finalI).setPeriod(time);
                                    Message msg = new Message();
                                    msg.what = 1;
                                    msg.arg1 = finalI;
                                    handler.sendMessage(msg);
                                }
                            }
                        }
                    }.start();
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();

            }
        }));
    }


    /**
     * 获取视频详情
     */
    private void getHomeVideo() {
        ApiUtil.getVideoApi().getHomeVideo(SPUtil.getToken(getContext()), id).observe(getViewLifecycleOwner(), new BaseObserver<>(new BaseObserverCallBack<ApiResponse<HomeVideoBean>>() {
            @Override
            public void onSuccess(ApiResponse<HomeVideoBean> data) {
                if (data.getErrorCode() == 0) {
                    if (null != data.getData()) {
                        if (null != data.getData().getInfo()) {
                            if (data.getData().getInfo().size() > 0) {
                                setHomeVideo(data.getData().getInfo().get(0));
                            }
                        }
                    }
                }
            }
        }));
    }

    private void setHomeVideo(HomeVideoBean.InfoDTO data) {
        uid = data.getUid();
        GlideImgManager.glideLoader(getContext(), data.getAvatar(), iv_summary_head, 0);
        tv_summary_nickname.setText(data.getNickName());
        if (data.getIsVip().equals("2")) {
            iv_summary_vip.setVisibility(View.GONE);
        } else {
            iv_summary_vip.setVisibility(View.VISIBLE);
        }
        if (data.getAuthentication().equals("2")) {
            iv_summary_goddess.setVisibility(View.GONE);
        } else {
            iv_summary_goddess.setVisibility(View.VISIBLE);
        }
        tv_summary_time.setText(data.getCreateTime());
        tv_summary_number.setText(data.getPageViews() + "次观看");
        if (data.getIfFollow().equals("2")) {
            tv_attention.setText("+关注");
        } else {
            tv_attention.setText("已关注");
        }
        tv_like_count.setText(data.getLikeCount());
        if (data.getIfLike().equals("1")) {
            iv_praise.setImageResource(R.mipmap.fabulous_3_img_true);
        } else {
            iv_praise.setImageResource(R.mipmap.fabulous_3_img);
        }
    }

    /**
     * 初始化数据
     */
    private void initRecyclerView() {
        rv_summary_data.setLayoutManager(new GridLayoutManager(getContext(), 2));

        mAdapter = new CommonRecyclerViewAdapter<VideoBean.InfoDTO.RecordsDTO>(getContext(), mList) {
            @Override
            public void convert(CommonRecyclerViewHolder holder, VideoBean.InfoDTO.RecordsDTO entity, int position) {

                GlideImgManager.glideLoader(getContext(), entity.getCover(), holder.getView(R.id.iv_recommend), 1);

                GlideImgManager.glideLoader(getContext(), entity.getAvatar(), holder.getView(R.id.iv_recommend_head), 0);

                holder.setText(R.id.tv_recommend_title, entity.getTitle());

                holder.setText(R.id.tv_recommend_nickname, entity.getNickname());

                holder.setText(R.id.tv_time, entity.getPeriod());

                if (entity.getIslike().equals("1")) {
                    ((ImageView) holder.getView(R.id.iv_fabulous)).setImageResource(R.mipmap.fabulous_img_true);
                } else {
                    ((ImageView) holder.getView(R.id.iv_fabulous)).setImageResource(R.mipmap.fabulous_img_false);
                }

                if (entity.getIsVip().equals("1")) {
                    ((ImageView) holder.getView(R.id.iv_vip)).setVisibility(View.VISIBLE);
                } else {
                    ((ImageView) holder.getView(R.id.iv_vip)).setVisibility(View.GONE);
                }
                if (!StringUt.isEmpty(entity.getAuthentication())) {
                    if (entity.getAuthentication().equals("1")) {
                        ((ImageView) holder.getView(R.id.iv_authentication)).setVisibility(View.VISIBLE);
                    } else {
                        ((ImageView) holder.getView(R.id.iv_authentication)).setVisibility(View.GONE);
                    }
                }
                holder.setText(R.id.tv_pageViews, entity.getPageViews());
                holder.setText(R.id.tv_fabulous, entity.getLikeCount());
                holder.setText(R.id.tv_comment_count, entity.getCommentCount());
            }

            @Override
            public int getLayoutViewId(int viewType) {
                return R.layout.item_recommend;
            }
        };

        rv_summary_data.setAdapter(mAdapter);

        mAdapter.setOnRecyclerViewItemClickListener(new CommonRecyclerViewAdapter.OnRecyclerViewItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                //先判断是否登录
                if (null != SPUtil.getObjectFromShare(getContext(),
                        Constants.USERINFO)) {
                    if (mList.get(position).getIsPaid().equals("1")) {
                        //免费还有次数
                        if (videoCount > 0) {
                            dialogFreePlay(mList.get(position).getId()
                                    , mList.get(position).getTitle());
                        } else {
                            //没有免费次数 弹出充值会员
                            dialogMember();
                        }
                    } else {
                        //收费
                        if (StringUt.isEmpty(mList.get(position).getIsFlag())) {
                            //为空 未购买
                            dialogPay(
                                    mList.get(position).getId(),
                                    mList.get(position).getMoney());
                        } else {
                            if (mList.get(position).getIsFlag().equals("0")) {
                                //未购买 弹出购买窗口
                                dialogPay(
                                        mList.get(position).getId(),
                                        mList.get(position).getMoney());
                            } else {//已购买
                                startActivity(new Intent(getContext(), VideoDetailsAc.class)
                                        .putExtra("id", mList.get(position).getId())
                                        .putExtra("title", mList.get(position).getTitle()));
                            }
                        }
                    }
                } else {
                    startActivity(new Intent(getContext(), LoginAc.class));
                }
            }
        });
    }


    @OnClick({R.id.rl_summary_layout, R.id.tv_attention, R.id.iv_praise, R.id.iv_share
            , R.id.iv_advertisement})
    public void setOnClick(View view) {
        switch (view.getId()) {
            case R.id.rl_summary_layout:
                String id = (String) SPUtil.get(getContext(), Constants.SP_ID, "");
                if (id.equals(uid)) {
                    //如果是自己
                    startActivity(new Intent(getContext(), HomepageAc.class));
                } else {
                    startActivity(new Intent(getContext(), OthersHomepageAc.class)
                            .putExtra("uid", uid));
                }
                break;
            case R.id.tv_attention:
                addorDeleteFocused();
                break;
            case R.id.iv_praise:
                addLike();
                break;
            case R.id.iv_share:
                dialogShare();
                break;
            case R.id.iv_advertisement:
                startActivity(new Intent(getContext(),
                        HomeLinkAc.class)
                        .putExtra("url", url));
                break;
        }
    }

    /**
     * 分享
     */
    private void dialogShare() {
        //1、使用Dialog、设置style
        final Dialog dialog = new Dialog(getContext(), R.style.DialogTheme);
        //2、设置布局
        View view = View.inflate(getContext(), R.layout.dialog_share, null);
        dialog.setContentView(view);

        TextView tv_cancel = view.findViewById(R.id.tv_cancel);
        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });

        TextView tv_share = view.findViewById(R.id.tv_share);
        tv_share.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //复制

            }
        });


        Window window = dialog.getWindow();
        //设置弹出位置
        window.setGravity(Gravity.CENTER);
        //设置弹出动画
        window.setWindowAnimations(R.style.main_menu_animStyle);
        //设置对话框大小
        window.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog.show();

    }

    /**
     * 点赞
     */
    private void addLike() {
        ApiUtil.getServiceApi().addLike(SPUtil.getToken(getContext()), id, "1").observe(getViewLifecycleOwner(), new BaseObserver<>(new BaseObserverCallBack<ApiResponse<UpdateUserBean>>() {
            @Override
            public void onSuccess(ApiResponse<UpdateUserBean> data) {
                getHomeVideo();
            }

            @Override
            public void onFinish() {
                super.onFinish();

            }
        }));
    }

    /**
     * 关注
     */
    private void addorDeleteFocused() {
        DeleteFocusedBean deleteFocusedBean = new DeleteFocusedBean();
        deleteFocusedBean.setUid(uid);
        ApiUtil.getUserApi().addorDeleteFocused(SPUtil.getToken(getContext()),
                deleteFocusedBean).observe(getViewLifecycleOwner(), new BaseObserver<>(new BaseObserverCallBack<ApiResponse<BaseBean>>() {
            @Override
            public void onSuccess(ApiResponse<BaseBean> data) {
                getHomeVideo();
            }
        }));
    }

    private String getPlayTime(String mUri) {
        MediaMetadataRetriever mmr = new MediaMetadataRetriever();
        String duration = "";
        try {
            if (mUri != null) {
                HashMap headers = null;
                if (headers == null) {
                    headers = new HashMap();
                    headers.put("User-Agent", "Mozilla/5.0 (Linux; U; Android 4.4.2; zh-CN; MW-KW-001 Build/JRO03C) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/1.0.0.001 U4/0.8.0 Mobile Safari/533.1");
                }
                mmr.setDataSource(mUri, headers);
            } else {
                //mmr.setDataSource(mFD, mOffset, mLength);
            }
            //注意地址 mUri= /storage/emulated/0/youshixiu/rectools/录屏专家190629113518.mp4    本地
            duration = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_DURATION);//时长(毫秒)
            String width = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);//宽
            String height = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);//高
        } catch (Exception ex) {
            Log.e("TAG", "MediaMetadataRetriever exception " + ex);
        } finally {
            mmr.release();
        }
        return duration;
    }

    public static String getFormatedDateTime(String pattern, long dateTime) {
        SimpleDateFormat sDateFormat = new SimpleDateFormat(pattern);
        return sDateFormat.format(new Date(dateTime + 0));
    }


    private boolean isValid(String urlString) {
        try {
            URL url = new URL(urlString);
            return URLUtil.isValidUrl(urlString) && Patterns.WEB_URL.matcher(urlString).matches();
        } catch (MalformedURLException e) {

        }
        return false;
    }

    /**
     * 弹出观看视频友情提示
     */
    private void dialogFreePlay(String id, String title) {
        //1、使用Dialog、设置style
        final Dialog dialog = new Dialog(getContext(), R.style.DialogTheme);
        //2、设置布局
        View view = View.inflate(getContext(), R.layout.dialog_home_play, null);
        dialog.setContentView(view);

        TextView tv_video_count = view.findViewById(R.id.tv_video_count);
        tv_video_count.setText(videoCount + "");

        LinearLayout ll_dialog_play = view.findViewById(R.id.ll_dialog_play);

        ll_dialog_play.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getContext(), VideoDetailsAc.class)
                        .putExtra("id", id)
                        .putExtra("title", title));
                dialog.dismiss();
            }
        });

        Window window = dialog.getWindow();
        //设置弹出位置
        window.setGravity(Gravity.CENTER);
        //设置弹出动画
//        window.setWindowAnimations(R.style.main_menu_animStyle);
        //设置对话框大小
        window.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog.show();

    }

    private void dialogMember() {
        //1、使用Dialog、设置style
        final Dialog dialog = new Dialog(getContext(), R.style.DialogTheme);
        //2、设置布局
        View view = View.inflate(getContext(), R.layout.dialog_home_member, null);
        dialog.setContentView(view);

        TextView tv_video_count = view.findViewById(R.id.tv_video_count);
        tv_video_count.setText(videoCount + "");

        Button bt_member = view.findViewById(R.id.bt_member);

        bt_member.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getContext(), MemberAc.class));
            }
        });


        Window window = dialog.getWindow();
        //设置弹出位置
        window.setGravity(Gravity.CENTER);
        //设置弹出动画
//        window.setWindowAnimations(R.style.main_menu_animStyle);
        //设置对话框大小
        window.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog.show();

    }

    /**
     * 购买
     */
    private void dialogPay(String id, String money) {
        //1、使用Dialog、设置style
        final Dialog dialog = new Dialog(getContext(), R.style.DialogTheme);
        //2、设置布局
        View view = View.inflate(getContext(), R.layout.dialog_play_video, null);
        dialog.setContentView(view);

        TextView tv_money = view.findViewById(R.id.tv_money);
        tv_money.setText("￥" + money);

        TextView tv_over = view.findViewById(R.id.tv_over);

        ImageView iv_close = view.findViewById(R.id.iv_close);

        iv_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });

        if (StringUt.isEmpty(over)) {
            tv_over.setText("￥0");
        } else {
            tv_over.setText("￥" + over);
        }

        TextView bt_play = view.findViewById(R.id.bt_play);

        bt_play.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!StringUt.isEmpty(money) && !StringUt.isEmpty(over)) {
                    if (Double.valueOf(over) > Double.valueOf(money)) {
                        //钱够支付
                        purchaseVideo(id, money);
                        dialog.dismiss();
                    } else {
                        Toast.makeText(getContext(), "余额不足", Toast.LENGTH_SHORT).show();
                    }
                } else if (StringUt.isEmpty(over)) {
                    Toast.makeText(getContext(), "余额不足", Toast.LENGTH_SHORT).show();
                }
            }
        });

        Window window = dialog.getWindow();
        //设置弹出位置
        window.setGravity(Gravity.BOTTOM);
        //设置弹出动画
//        window.setWindowAnimations(R.style.main_menu_animStyle);
        //设置对话框大小
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog.show();

    }

    /**
     * 余额购买视频
     *
     * @param id
     * @param money
     */
    private void purchaseVideo(String id, String money) {
        dialogPass(id, money);
    }

    /**
     * 支付密码
     */
    private void dialogPass(String id, String money) {
        PurchaseVideoBean purchaseVideoBean = new PurchaseVideoBean();
        purchaseVideoBean.setId(id);
        purchaseVideoBean.setMoney(money);

        final PayPassDialog dialog = new PayPassDialog(getContext());
        dialog.getPayViewPass()
                .setRandomNumber(true)
                .setPayClickListener(new PayPassView.OnPayClickListener() {
                    @Override
                    public void onPassFinish(String passContent) {
                        //6位输入完成回调
                        Log.d("ret", "joker  输入的密码===" + passContent);
                        purchaseVideoBean.setPayPassWord(passContent);

                        ApiUtil.getVideoApi().purchaseVideo(SPUtil.getToken(getContext()),
                                purchaseVideoBean).observe(getViewLifecycleOwner(), new BaseObserver<>(new BaseObserverCallBack<ApiResponse<BaseBean>>() {
                            @Override
                            public void onSuccess(ApiResponse<BaseBean> data) {
                                if (data.getData().getCode() == 0) {
                                    Toast.makeText(getContext(), "购买成功", Toast.LENGTH_SHORT).show();
                                    dialog.dismiss();
                                    getGuessLikeVideo();
                                    queryById();
                                }
                            }
                        }));
                    }

                    @Override
                    public void onPayClose() {
                        dialog.dismiss();
                        //关闭弹框
                    }

                    @Override
                    public void onPayForget() {
                        dialog.dismiss();
                        //点击忘记密码回调
                    }
                });

    }

}
